package com.SmartCampus.system.service.impl;

import com.SmartCampus.system.mapper.FeedbackMapper;
import com.SmartCampus.system.model.dto.feedback.FeedbackQueryRequest;
import com.SmartCampus.system.model.entity.Feedback;
import com.SmartCampus.system.model.vo.FeedbackVO;
import com.SmartCampus.system.service.FeedbackService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author wangliang
* @description 针对表【feedback(反馈表)】的数据库操作Service实现
* @createDate 2024-12-26 18:54:38
*/
@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback>
    implements FeedbackService {

    @Resource
    private FeedbackMapper feedbackMapper;

    @Override
    public Page<FeedbackVO> getFeedbackByAll(Page<FeedbackVO> page, FeedbackQueryRequest feedbackQueryRequest) {
        List<FeedbackVO> feedbackVOList = feedbackMapper.getFeedbackByAll(page, feedbackQueryRequest);
        if (feedbackVOList == null){
            throw new RuntimeException("查询失败，请联系管理员");
        }
        page.setRecords(feedbackVOList);
        return page;
    }

    @Override
    public Page<FeedbackVO> getFeedbackByMy(Page<FeedbackVO> page, FeedbackQueryRequest feedbackQueryRequest, Long userId) {
        List<FeedbackVO> feedbackList = feedbackMapper.getFeedbackByMy(page, feedbackQueryRequest, userId);
        if (feedbackList == null){
            throw new RuntimeException("查询失败，请联系管理员");
        }
        page.setRecords(feedbackList);
        return page;
    }
}




